﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DearlerPlatform.Core.DataBaseCommon
{
    public class QueryParameterBase
    {

        /*
            Equal=0 相等
            Like=1 模糊查询
            GreaterThan=2 大于
            GreaterThanOrEqual=3 大于等于
            LessThan=4 小于
            LessThanOrEqual=5 小于等于
            In=6 In操作 正确格式   X,Y,Z  错误格式   'X','Y','z'
            NotIn=7 Not in操作 参数和in一样
            LikeLeft=8  左模糊
            LikeRight=9  右模糊
            NoEqual=10 不等于
            IsNullOrEmpty=11 是null或者''
            IsNot=12  情况1   value不等于null  字段<> x 情况2   value等于null  字段 is not null
            NoLike=13 模糊查询取反
            EqualNull=14 情况1   value不等于null 字段= x 情况2   value等于null  字段 is null
            InLike=15 正确格式   X,Y,Z  错误格式   'X','Y','z' 生在的Sql ：   ( id like '%X%' or id like '%Y%' or id like '%Z%')
         */
        // Key表式运算符:   And =0，  Or=1,  null=-1

        /*
     {
	"pageNum": 1,
	"pageSize": 50,
	"conditionalList": [{
			"key": -1,
			"value": {
				"fieldName": "ProductName",
				"fieldValue": "架子",
				"conditionalType": 1
			}
		},
		{
			"key": 0,
			"value": {
				"fieldName": "TypeName",
				"fieldValue": "产品",
				"conditionalType": 1
			}
		},
		{
			"key": 0,
			"value": {
				"fieldName": "TypeNo",
				"fieldValue": "CL",
				"conditionalType": 1
			}
		}
	],
	"orderBys": [
		"Id desc"
	]
}    
         
         */

        /// <summary>
        /// 页码
        /// </summary>
        [Required(ErrorMessage = "页码不能为空")]
        public int PageNum { get; set; }
        /// <summary>
        /// 每页显示条数
        /// </summary>
        [Required(ErrorMessage = "每页显示多少条不能为空")]
        [Range(1, 150, ErrorMessage = "每页显示多少条不能小于1或大于150")]
        public int PageSize { get; set; }
        /// <summary>
        /// 查询参数集合
        /// </summary>
        public List<QueryConditionalList> ConditionalList { get; set; }

        /// <summary>
        /// 排序字段
        /// </summary>
        public List<string> OrderBys { get; set; }
    }
}
